// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
  const sequelizeClient = app.get('sequelizeClient');
  const users = sequelizeClient.define('users', {
  
    // 对于我们的数据库要存储的内容的字段的声明
    username: {
      type: DataTypes.STRING,
      allowNull: false, // allowNull 默认为 true  如果设置为 false 则该列不允许为 null
      unique: true, //  unique  如果为 true 则该列的值必须唯一，不能重复
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false
    },
    sex: DataTypes.INTEGER,// 性别 0 男 1 女
    idNum: {
      type: DataTypes.STRING,
      unique: true
    }, // 身份证号
    phone:{
      type: DataTypes.STRING,
    }
  
  
  }, {
    hooks: {
      beforeCount(options) {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line no-unused-vars
  users.associate = function (models) {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return users;
};
